//求一个字符串中包含的最大的16进制数
//0-F 匹配

function solve(s) {

    //16进制的正则
    let reg = /[0-9a-fA-F]+/g;
    let res = s.match(reg);
    // let res = reg.exec(s);
    console.log(res);

    //求10进制的最大值
    let max = 0;
    res.forEach(e => {
        // let temp = sum(e);
        let temp = parseInt(e, 16);
        if (max < temp) {
            max = temp;
        }
    });
    return max;
}

function sum(s) {
    let strs = s.split(''); //匹配到的16进制字符数组
    // console.log(res[0]);
    //转化成10进制

    let reg2 = /[a-fA-F]/;
    let sum = 0; //求和,十进制返回
    for (let i = 0; i < strs.length; i++) {
        let element = strs[i];
        if (reg2.test(element)) {
            //如果是a-f
            switch (element.toUpperCase()) {
                case 'A':
                    element = 10;
                    break;
                case 'B':
                    element = 11;
                    break;
                case 'C':
                    element = 12;
                    break;
                case 'D':
                    element = 13;
                    break;
                case 'E':
                    element = 14;
                    break;
                case 'F':
                    element = 15;
                    break;
                default:
                    break;
            }
        }
        sum += element * (16 ** (strs.length - 1 - i));
    }

    return sum;
}
module.exports = {
    solve: solve
};

console.log(solve("UR11645E64O45CACC1GR1560C303X1A24CDCBYLX1616D491I"));